package ribbonconfiguration;

import com.lee.demonacosclient.configuration.NacosClusterWeightRule;
import com.lee.demonacosclient.configuration.NacosVersionWeightRule;
import com.lee.demonacosclient.configuration.NacosWeightRule;
import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName RibbonConfiguration
 * @Description , 这个类的包一定要写在 启动类扫描不到的位置. 避免父子上下文的扫描重叠. 父子上下文重叠可能会导致事务不生效.
 * 而且会导致这个配置全局生效.
 * @Author leejiliang
 * @DateTime 2020/9/19 9:12 PM
 * @Version 1.0
 */
@Configuration
public class RibbonConfiguration {

	/**
	 * 返回一个随机的算法的负载均衡策略,和轮询不同
	 * @return
	 */
	@Bean
	public IRule ribbonRule() {
		return new NacosVersionWeightRule();
	}
}
